﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Engine.Mathematics;
using System.IO;

namespace Engine.Helper
{
    [Obsolete("this class used only for debug purposes")]
    public class MatrixToFileUtils
    {
        private const string FILE = "D:/Data.txt";

        public static void SaveToFile(Matrix matrix,Vector vector)
        {
            File.Delete(FILE);
            FileStream io = File.OpenWrite(FILE);
            StreamWriter writer = new StreamWriter(io);
            for (int i = 0; i < matrix.Rows; i++)
            {
                StringBuilder line = new StringBuilder();
                for (int j = 0; j < matrix.Cols; j++)
                {
                    if (matrix[i, j] >= 0)
                    {
                        line.Append("  ");
                    }
                    else
                    {
                        line.Append(" ");
                    }
                    line.Append(matrix[i, j]);
                }
                if (vector[i] >= 0)
                {
                    line.Append("  ");
                }
                else
                {
                    line.Append(" ");
                }
                line.Append(vector[i]);
                writer.WriteLine(line.ToString());
            }
            writer.Close();
        }
    }
}
